package viettravel.guiandevent.place;

import java.util.List;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class GalleryImageAdapter extends BaseAdapter{

	private Context mContext;	
	private ImageView mImageView;
	private List<Drawable> mListImages;
	private ViewHolder mHolder;
	private int mWidth;
	private int mHeight;
	
	public GalleryImageAdapter(Context context, List<Drawable> plotsImages, int width, int height) {
		mContext = context;
		this.mListImages = plotsImages;
		mWidth = width;
		mHeight = height;
	}
	public void setListImage(List<Drawable> listImages){
		mListImages = listImages;
	}
	@Override
	public int getCount() {
		return mListImages.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			mHolder = new ViewHolder();
			mImageView = new ImageView(mContext);
			mImageView.setPadding(0, 0, 0, 0);
			convertView = mImageView;
			mHolder.imageView = mImageView;
			convertView.setTag(mHolder);
		} else {
			mHolder = (ViewHolder) convertView.getTag();
		}
		mHolder.imageView.setImageDrawable(mListImages.get(position));
		mHolder.imageView.setScaleType(ImageView.ScaleType.FIT_XY);
		mHolder.imageView.setLayoutParams(new Gallery.LayoutParams(mWidth, mHeight));
		return mImageView;
	}
	
	private static class ViewHolder {
		ImageView imageView;
	}

}
